<template>
  <div class="experience">
    <div class="experienceBox">
      <h1 class="regionalTitle">瑟语的传奇人生</h1>
      <div class="contentBox">
        <!--左侧内容-->
        <div class="contentLeft">
          <div class="leftTop">
            <div
              v-for="item in school"
              :key="item.id"
              class="contentItem"
              v-inter:inter
              @click="openDialog(item.description)"
            >
              <h3>{{item.title}}</h3>
              <div>{{item.name}}</div>
            </div>
          </div>
          <div class="leftBottom" v-inter:inter>
            <div class="orderContent">
              <h4 class="orderTitle">侧耳聆听，心揽万物。</h4>
              <div v-for="item in order" :key="item.id" class="experienceLink">
                <span>{{item.name}}：</span>
                <a :href="item.url" target="seyu">
                  {{screenWidth > 500 ? item.url : item.label}}
                </a>
              </div>
              <div class="experienceLink">
                我曾一度在意别人的眼光，因而不知这世界的美好，我曾努力成为众人所期待的模样，但却永远都得不到认可。
                我紧握着双手，想要抓住一切，里面却什么都没有，而当我打开双手，世界--就在我的手中。
              </div>
            </div>
          </div>
        </div>
        <!--右侧内容-->
        <div class="contentRight">
          <div class="rightBox">
            <div
                v-for="item in society"
                :key="item.id"
                class="contentItem"
                v-inter:inter
                @click="openDialog(item.description)"
            >
              <h3>{{item.title}}</h3>
            </div>
          </div>
        </div>
      </div>
    </div>
    <ExperienceDetail v-model="dialogVisible" :dialogContent="dialogContent" />
  </div>
</template>

<script setup>
import { ref, reactive, onBeforeMount } from 'vue'
import {http} from "../axios/index.js";

import ExperienceDetail from "./ExperienceDetail.vue"

// 数据
const school = reactive([])
const society = reactive([])
const order = reactive([])
// 获取数据
async function getExperience() {
  const res = await http({url: "/get_experience"})
  if(res.data.code === 0) {
    school.push(...res.data.data.school)
    society.push(...res.data.data.society)
    order.push(...res.data.data.order)
  }
}

// 弹窗
const dialogVisible = ref(false)
const dialogContent = ref("")
// 打开弹窗
function openDialog(value) {
  dialogContent.value = value
  dialogVisible.value = true
}

const screenWidth = ref(window.innerWidth)
window.addEventListener('resize', () => {
  screenWidth.value = window.innerWidth
})
onBeforeMount(()=>{
  getExperience()
})
</script>

<style scoped>
.experience {
  background: url("/assets/experience/experience_bg.jpg") top;
}
.experienceBox {
  width: 90vw;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%,-50%);
}
.contentBox {
  height: calc(100vh - 100px);
  display: grid;
  grid-template-columns: 70% 30%;
  padding-top: 20px;
}
/*左侧内容*/
.contentBox .contentLeft{
  display: flex;
  flex-direction: column;
}
.contentBox .contentLeft .leftTop {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-gap: 20px;
  padding-bottom: 20px;
}
/*左侧下部分内容*/
.contentBox .contentLeft .leftBottom {
  flex: 1;
  background: url("/assets/experience/experience_border.png");
  background-size: 100% 100%;
  position: relative;
  opacity: 0;
}
.contentBox .contentLeft .leftBottom .orderContent {
  width: 85%;
  height: 60%;
  overflow: auto;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%,-50%);
}
.orderContent .orderTitle {
  text-align: center;
  line-height: 1.4;
}
.orderContent .experienceLink {
  width: 100%;
  max-width: 450px;
  margin: 0 auto;
  padding: .25em;
}
.orderContent .experienceLink span {
  width: 20%;
  min-width: 70px;
  display: inline-block;
}
.orderContent .experienceLink a {
  text-decoration: none;
  color: #444444;
  font-style: italic;
  border-bottom: 1px dashed #444444;
}
.orderContent .experienceLink a:hover {
  color: #ff6ec7;
  border-bottom-color: #ff6ec7;
}
/*右侧内容*/
.contentRight {
  height: 100%;
  overflow: auto;
  padding: 0 20px;
}
.contentRight .rightBox {
  display: grid;
  grid-template-columns: repeat(1,1fr);
  grid-gap: 20px;
}
/*每一项内容*/
.contentBox .contentItem {
  text-align: center;
  backdrop-filter: blur(5px);
  box-shadow: 5px 5px 10px #444444;
  border-radius: 10px;
  padding: 15px 0;
  opacity: 0;
  cursor: pointer;
}

@media (max-width: 800px){
  .contentBox {
    grid-template-columns: 1fr;
    overflow: auto;
  }
  .contentBox .contentLeft {
    padding: 0 20px;
  }
  .contentBox .contentLeft .leftBottom {
    width: 100%;
    aspect-ratio: 658/537;
  }
  .contentRight {
    overflow: unset;
  }
}
@media (max-width: 500px) {
  .contentBox .contentLeft .leftTop {
    grid-template-columns: 1fr;
  }
}
</style>